package com.gongpingjialoan.activity.main;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.gongpingjialoan.R;
import com.gongpingjialoan.activity.car.BargainRecordActivity;
import com.gongpingjialoan.activity.car.ContractActivity;
import com.gongpingjialoan.activity.car.MeetRecordActivity;
import com.gongpingjialoan.bean.Monitor;
import com.gongpingjialoan.utility.StepMonitor;

/**
 * Created by Administrator on 2017/2/21.
 */
public class OperateActivity extends BaseActivity implements OnClickListener {

    private TextView contract_num;
    private View meet_record_rl, contractView, bargain_record_rl;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.operate_layout);
        setTitle("操作记录");
        contractView = findViewById(R.id.lianxi_id);
        meet_record_rl = findViewById(R.id.meet_record_rl);
        contract_num = (TextView) findViewById(R.id.contract_num);
        bargain_record_rl = findViewById(R.id.bargain_record_rl);
        String contact = getIntent().getStringExtra("contract_num");
        if (!TextUtils.isEmpty(contact) && !"0".equals(contact)) {
            contract_num.setVisibility(View.VISIBLE);
            contract_num.setText("已联系过" + contact + "辆车");
        } else {
            contract_num.setVisibility(View.GONE);
        }
        bargain_record_rl.setOnClickListener(this);
        contractView.setOnClickListener(this);
        meet_record_rl.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v == contractView) {
            StepMonitor.getInstance().addMonitor(new Monitor("click", "my_contactRecord", System.currentTimeMillis(), 1f));
            startActivity(new Intent(this, ContractActivity.class));
        } else if (v == bargain_record_rl) {
            StepMonitor.getInstance().addMonitor(new Monitor("click", "my_bargainRecord", System.currentTimeMillis(), 1f));
            startActivity(new Intent(this, BargainRecordActivity.class));
        } else if (v == meet_record_rl) {
            StepMonitor.getInstance().addMonitor(new Monitor("click", "my_appointRecord", System.currentTimeMillis(), 1f));
            startActivity(new Intent(this, MeetRecordActivity.class));
        }
    }
}
